package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.entity.DishFlavor;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface DishMapper {

    Page<Dish> pageSelect(DishPageQueryDTO dishPageQueryDTO);

    @Select("select * from dish where category_id=#{categoryId}")
    List<Dish> selectById(String categoryId) ;

    void addDishFlavor(DishFlavor dishFlavor);

    void addDish(Dish dish);

    @Select("select *from dish_flavor where id=#{id}")
    List<DishFlavor> findFlavors(Long id);

    @Select("select name,category_id,price,image,description,status,update_time from dish where id=#{id}")
    Dish findDish(Long id);

    void updateDish(Dish dish);

    void updateFlavor(DishFlavor dishFlavor);

    @Delete("delete from dish_flavor where id=#{id}")
    void deleteById(Long id);

    @Delete("delete from dish_flavor where id=#{id}")
    void deleteFlavor(Long id);

    @Update("update dish set status=#{status} where id=#{id}")
    void startOrStop(Integer status, Long id);

    @Delete("delete from dish where id=#{id}")
    void deleteDish(Long id);
}
